//https://leetcode.cn/problems/count-numbers-with-unique-digits/submissions/582548104/
class Solution {
public:
    int countNumbersWithUniqueDigits(int n) {
        if (n == 0) return 1;
        else if (n == 1) return 10;
        int sum = 10;
        for (int i = 2; i <= n; i++) {
            int cnt = 9;
            for (int j = 0; j < i - 1; j++) {
                cnt = cnt * (9 - j);
            }
            sum += cnt;
        }
        return sum;
    }
};